/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-06-06     CGY       the first version
 */
#ifndef APPLICATIONS_HEADER_FILE_REMOTE_CTRL_H_
#define APPLICATIONS_HEADER_FILE_REMOTE_CTRL_H_

enum
{
    ROL ,
    PIT ,
    THR ,
    YAW ,
    AUX1 ,
    AUX2 ,
    AUX3 ,
    AUX4 ,
    AUX5 ,
    AUX6 ,
    CH_NUM
};


typedef enum
{
    LO = 0,
    CE = 1,
    HI = 2,
}CH_Pos;                            //通道档位
enum
{
    OFF = 0,
    ON  = 1,
};
typedef enum
{
    acce_mode = 0,
    sped_mode = 1,
}Height_Ctrl;
enum
{
    lock    = 0,
    unlock  = 1,
    waitunlock,
    ESC_Cali,
};

/* 飞行模式标志位 */
typedef union
{
    uint32_t AllMarks;
    struct
    {
        uint32_t Stabilize   :1;        //自稳模式
        uint32_t Altitude    :1;        //定高模式
        uint32_t Position    :1;        //定点模式
        uint32_t Headless    :1;        //无头模式
        uint32_t Auto        :1;        //外部控制
        uint32_t Fence       :1;        //外部控制
        uint32_t reserve1      :1;        //外部控制
        uint32_t reserve2      :1;        //外部控制
        uint32_t reserve3      :1;        //外部控制
        uint32_t reserve4      :1;        //外部控制
        uint32_t reserve5      :1;        //外部控制
        uint32_t Finder      :1;        //蜂鸣器常开,寻机模式

        uint32_t Ready       :1;        //飞机就绪
        uint32_t Height_ctrl :1;        //高度控制模式:油门/定速
        uint32_t BodyState   :3;
    };
}Flight_state;
typedef enum
{
    Stabilize   ,
    Fly_Altitude    ,
    Position    ,
    Headless    ,
    One_key_fly ,
    Beeper
}Flifht_state_show;

typedef struct
{
    uint16_t    rc_raw[CH_NUM];      //储存遥控器原始数据9xx~20xx
    uint16_t    rc_ori[CH_NUM];      //规范数据范围至1000-2000
    int16_t     rc_norm[CH_NUM];     //规范数据范围至-500-500
    float       rc_uint[CH_NUM];     //遥控器原始数据加死区后单位化
    int16_t     rc_dat[CH_NUM];      //遥控器单位化数据乘500;
    CH_Pos      ch_state[CH_NUM];    //辅助通道位置状态

    Flight_state    Flyflag;         //飞机运行标志

    void (*rcUpdate)(uint8_t ms);
    float (*datswitch)(float unit, float max);

}RC_HandleTypedef;
extern RC_HandleTypedef RC_Handle;

void RC_Task(void *parameter);
#endif /* APPLICATIONS_HEADER_FILE_REMOTE_CTRL_H_ */
